package com.lw.alarm.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lw.alarm.model.AlarmNoticeLog;
import com.lw.alarm.model.AlarmServer;
import com.lw.alarm.service.AlarmNoticeLogService;
import com.lw.common.basemodel.EasyuiModel;
import com.lw.common.core.service.BaseServiceI;
import com.lw.common.util.ModelConvertUtil;
import com.lw.common.web.controller.BaseController;

@RestController
@RequestMapping("/alarmNoticeLog")
public class AlarmNoticeLogController extends BaseController<AlarmNoticeLog, Integer> {
	@Resource
	private AlarmNoticeLogService alarmNoticeLogService;

	@Override
	public BaseServiceI<AlarmNoticeLog, Integer> getBaseService() {
		return alarmNoticeLogService;
	}

	@InitBinder
	public void initBinder(ServletRequestDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	}
	
	@GetMapping("list")
	public EasyuiModel<AlarmServer> findUserAndRolesByPage(AlarmNoticeLog r, int page, int rows) {
		return ModelConvertUtil.pageInfo2EasyuiModel(alarmNoticeLogService.findAlarmNoticeLogByPage(r, page, rows));
	}
}
